package cn.itsource.basic.controller;

import cn.itsource.basic.dto.AdminLoginDto;
import cn.itsource.basic.dto.BinderAccountDto;
import cn.itsource.basic.dto.CodeDto;
import cn.itsource.basic.service.ILoginService;
import cn.itsource.basic.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    @PostMapping("/account")
    public AjaxResult accountLogin(@RequestBody AdminLoginDto adminLoginDto){
        return loginService.login(adminLoginDto);
    }

    @PostMapping("/wechat")
    public AjaxResult wechatLogin(@RequestBody CodeDto codeDto){
         return loginService.wechatLogin(codeDto);
    }

    @PostMapping("/binder")
    public AjaxResult binder(@RequestBody BinderAccountDto binderAccountDto){
        return loginService.binder(binderAccountDto);
    }
}
